// map
// Created by FanGccU on 2025/6/23.
// 根据key的元素值进行升序排序

#include <iostream>
#include <map>
using namespace std;


void func1() {
    // 创建一个 map 容器，存储员工的姓名和年龄
    map<string, int> employees;

    employees["xiaoming"] = 18;
    employees["xiaohong"] = 20;
    employees["zhangsan"] = 22;

    // 查询 xiaoming 是否存在
    if (employees.find("xiaoming") != employees.end()) {
        cout << "age of xiaoming is :\t" << employees["xiaoming"] << endl;
        // 移除 xiaoming
        employees.erase("xiaoming");
    }

    cout << "map values :" << endl;
    for (map<string, int>::iterator it = employees.begin(); it != employees.end(); ++it) {
        cout << it->first << "\t:\t" << it->second << endl;
    }
}

void func2() {
    // 创建一个 map 容器，存储员工的姓名和年龄
    map<int, string> employees;

    employees[50] = "xiaobai";
    employees[20] = "xiaohuang";
    employees[10] = "xiaolv";

    cout << "map values :" << endl;
    for (map<int, string>::iterator it = employees.begin(); it != employees.end(); ++it) {
        cout << it->first << "\t:\t" << it->second << endl;
    }
}

int main(int argc, char *argv[]) {
    // func1();
    func2();
}
